package Composite;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;

public class ComponentPatternMain extends Application{
    public static void main(String[] args){
        launch(args);

        //安全组合模式
    }

	@Override
	public void start(Stage primaryStage) throws Exception {
		// TODO Auto-generated method stub
		SafeFolder safeFileManager = new SafeFolder("安全文件管理器");
		FlowPane pane = new FlowPane();
		BorderPane borderPane = new BorderPane();

		Button button1a = new Button("新建节点sa");
		button1a.setOnMouseClicked(e->{
			SafeFolder sa = new SafeFolder("sa");
			safeFileManager.add(sa);
		});
		Button button1b = new Button("新建节点sb");
		button1b.setOnMouseClicked(e->{
			SafeFolder sa = new SafeFolder("sb");
			safeFileManager.add(sa);
		});
		Button button1c = new Button("新建节点sc");
		button1c.setOnMouseClicked(e->{
			SafeFolder sa = new SafeFolder("sc");
			safeFileManager.add(sa);
		});

		Button button2 = new Button("显示节点");
		button2.setOnMouseClicked(e->{
			safeFileManager.operate();
		});

		pane.getChildren().addAll(button1a, button1b, button1c);
		borderPane.setCenter(pane);
		borderPane.setBottom(button2);
		pane.setPadding(new Insets(50, 50, 50, 50));
		Scene scene = new Scene(borderPane, 400, 300);
		primaryStage.setTitle("Composite");
		primaryStage.setScene(scene);
		primaryStage.show();
	}
}
